package com.situ.stmall.manger.mapper;

import com.situ.stmall.manger.entity.GoodsPic;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GoodsPicMapper {
    //批量插入
    @Insert({"<script>",
            "insert into goods_pic",
            "(url,goods_id)",
            "value",
            "<foreach collection='pics' item='pic' separator=','>",
            "(#{pic.url},#{pic.goodsId})",
            "</foreach>",
            "</script>",
    })
    int insert(@Param("pics") List<GoodsPic> pics);


    //删除
    @Delete("delete from goods_pic where goods_id=#{goodsId}")
    int deleteByGoodsId(Integer goodsId);

    //根据商品Id查询
    @Select("select * from goods_pic where goods_id=#{goodsId}")
    List<GoodsPic> selectByGoodsId(Integer goodsId);
}
